Skip to main content

Common Mistakes & Anti-Patterns

This section documents real mistakes repeatedly seen in production automation frameworks. Avoiding these is as important as knowing the correct implementation.


1️⃣ Creating Reports Inside Test Classes βŒβ€‹

Why People Do This​

  • Simplicity
  • Copy-paste from tutorials

Why It Fails​

  • Breaks parallel execution
  • Causes duplicate reports
  • Violates separation of concerns

βœ” Correct: Initialize reports in listeners / framework layer


2️⃣ Using Static ExtentTest Variables βŒβ€‹

public static ExtentTest test;

Why It Fails​

  • Shared across threads
  • Log mixing
  • Wrong screenshots

βœ” Correct: Use ThreadLocal<ExtentTest>


3️⃣ Flushing Reports Multiple Times βŒβ€‹

Common Misuse​

  • Flushing after every test
  • Flushing inside @AfterMethod

Impact​

  • Corrupted HTML
  • Missing logs

βœ” Correct: Flush once in suite completion


4️⃣ Logging Everything βŒβ€‹

Examples:

  • Every Selenium call
  • Every framework method

Impact​

  • Huge unreadable reports
  • Business users stop reading

βœ” Correct: Log intent, not implementation


5️⃣ Screenshot Abuse βŒβ€‹

What Goes Wrong​

  • Screenshot on every step
  • Overwriting screenshot files

Impact​

  • Slow execution
  • Incorrect attachments

βœ” Correct: Screenshot on failure + critical steps only


6️⃣ Hardcoded Paths βŒβ€‹

Examples​

  • C:/Users/...
  • Local desktop paths

Impact​

  • CI failures
  • Non-portable framework

βœ” Correct: Relative paths + workspace-aware locations


7️⃣ Ignoring Thread Cleanup βŒβ€‹

What Happens​

  • Memory leaks
  • Unstable reports in long runs

βœ” Correct:

extentTest.remove();

8️⃣ Over-Customization βŒβ€‹

Examples​

  • Heavy CSS/JS
  • UI hacks

Impact​

  • Fragile reports
  • Upgrade pain

βœ” Correct: Minimal, meaningful customization


9️⃣ Mixing Reporting With Assertions βŒβ€‹

Bad Practice​

test.fail("Assertion failed");
Assert.fail();

Impact​

  • Duplicate failures
  • Confusing reports

βœ” Correct: Assertions fail tests, listeners report them


πŸ” Self-Audit Checklist​

Before committing your framework, confirm:

βœ” One report per execution βœ” ThreadLocal usage present βœ” Listeners control lifecycle βœ” CI reports always published βœ” No test-level report code


🧠 Final Takeaway​

Most Extent Reports problems are design problems, not library problems.

Avoiding these anti-patterns guarantees stable, trustworthy reports.